bitkeeper revision 1.1159.170.56 (41b4b01dWSU8yr3EZRTsBs0QnHMwxQ)
authorcl349@arcadians.cl.cam.ac.uk <cl349@arcadians.cl.cam.ac.uk>
Mon, 6 Dec 2004 19:16:45 +0000 (19:16 +0000)
committercl349@arcadians.cl.cam.ac.uk <cl349@arcadians.cl.cam.ac.uk>
Mon, 6 Dec 2004 19:16:45 +0000 (19:16 +0000)
sync w/ head

.rootkeys
linux-2.4.27-xen-sparse/include/linux/irq.h [deleted file]
linux-2.4.28-xen-sparse/include/linux/irq.h [new file with mode: 0644]
linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile [new file with mode: 0644]
linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c [new file with mode: 0644]
linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/entry.S
linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile [deleted file]
linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c [deleted file]

index dcc00d20722c2b367f7d3a09a2ab0a5ea059dcc1..db1ca74926afdb124bcddd69c07bc91a9190759d 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -44,7 +44,6 @@
 3f815145vGYx1WY79voKkZB9yKwJKQ extras/mini-os/time.c
 3f815145xlKBAQmal9oces3G_Mvxqw extras/mini-os/traps.c
 4187ca95_eQN62ugV1zliQcfzXrHnw install.sh
-419e0488SBzS3mdUhwgsES5a5e3abA linux-2.4.27-xen-sparse/include/linux/irq.h
 3e5a4e6589G-U42lFKs43plskXoFxQ linux-2.4.28-xen-sparse/Makefile
 3e5a4e65IEPjnWPZ5w3TxS5scV8Ewg linux-2.4.28-xen-sparse/arch/xen/Makefile
 3e5a4e65n-KhsEAs-A4ULiStBp-r6w linux-2.4.28-xen-sparse/arch/xen/boot/Makefile
 3f1056a9L_kqHcFheV00KbKBzv9j5w linux-2.4.28-xen-sparse/include/asm-xen/vga.h
 40659defgWA92arexpMGn8X3QMDj3w linux-2.4.28-xen-sparse/include/asm-xen/xor.h
 3f056927gMHl7mWB89rb73JahbhQIA linux-2.4.28-xen-sparse/include/linux/blk.h
+419e0488SBzS3mdUhwgsES5a5e3abA linux-2.4.28-xen-sparse/include/linux/irq.h
 4124f66fPHG6yvB_vXmesjvzrJ3yMg linux-2.4.28-xen-sparse/include/linux/mm.h
 401c0590D_kwJDU59X8NyvqSv_Cl2A linux-2.4.28-xen-sparse/include/linux/sched.h
 40a248afgI0_JKthdYAe8beVfXSTpQ linux-2.4.28-xen-sparse/include/linux/skbuff.h
 40f56238eczveJ86k_4hNxCLRQIF-g linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/Makefile
 40f56238rXVTJQKbBuXXLH52qEArcg linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/Makefile
 40f562385s4lr6Zg92gExe7UQ4A76Q linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/common.c
+41ab440bnpxZdWShZrGgM9pPaz5rmA linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile
+41ab440bBKWz-aEOEojU4PAMXe3Ppg linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c
 40f56238XDtHSijkAFlbv1PT8Bhw_Q linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/entry.S
 40f56238bnvciAuyzAiMkdzGErYt1A linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/head.S
 40f58a0d31M2EkuPbG94ns_nOi0PVA linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/i386_ksyms.c
 410a94a4KT6I6X0LVc7djB39tRDp4g linux-2.6.10-rc2-xen-sparse/mm/page_alloc.c
 41505c572m-s9ATiO1LiD1GPznTTIg linux-2.6.10-rc2-xen-sparse/net/core/skbuff.c
 4149ec79wMpIHdvbntxqVGLRZZjPxw linux-2.6.10-rc2-xen-sparse/net/ipv4/raw.c
-41ab440bnpxZdWShZrGgM9pPaz5rmA linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile
-41ab440bBKWz-aEOEojU4PAMXe3Ppg linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c
 413cb1e4zst25MDYjg63Y-NGC5_pLg netbsd-2.0-xen-sparse/Makefile
 413cb1e5c_Mkxf_X0zimEhTKI_l4DA netbsd-2.0-xen-sparse/mkbuildtree
 413cb1e5kY_Zil7-b0kI6hvCIxBEYg netbsd-2.0-xen-sparse/nbconfig-xen
diff --git a/linux-2.4.27-xen-sparse/include/linux/irq.h b/linux-2.4.27-xen-sparse/include/linux/irq.h
deleted file mode 100644 (file)
index 7052672..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef __irq_h
-#define __irq_h
-
-/*
- * Please do not include this file in generic code.  There is currently
- * no requirement for any architecture to implement anything held
- * within this file.
- *
- * Thanks. --rmk
- */
-
-#include <linux/config.h>
-
-#if !defined(CONFIG_ARCH_S390)
-
-#include <linux/cache.h>
-#include <linux/spinlock.h>
-
-#include <asm/irq.h>
-#include <asm/ptrace.h>
-
-/*
- * IRQ line status.
- */
-#define IRQ_INPROGRESS 1       /* IRQ handler active - do not enter! */
-#define IRQ_DISABLED   2       /* IRQ disabled - do not enter! */
-#define IRQ_PENDING    4       /* IRQ pending - replay on enable */
-#define IRQ_REPLAY     8       /* IRQ has been replayed but not acked yet */
-#define IRQ_AUTODETECT 16      /* IRQ is being autodetected */
-#define IRQ_WAITING    32      /* IRQ not yet seen - for autodetection */
-#define IRQ_LEVEL      64      /* IRQ level triggered */
-#define IRQ_MASKED     128     /* IRQ masked - shouldn't be seen again */
-#define IRQ_PER_CPU    256     /* IRQ is per CPU */
-
-/*
- * Interrupt controller descriptor. This is all we need
- * to describe about the low-level hardware. 
- */
-struct hw_interrupt_type {
-       const char * typename;
-       unsigned int (*startup)(unsigned int irq);
-       void (*shutdown)(unsigned int irq);
-       void (*enable)(unsigned int irq);
-       void (*disable)(unsigned int irq);
-       void (*ack)(unsigned int irq);
-       void (*end)(unsigned int irq);
-       void (*set_affinity)(unsigned int irq, unsigned long mask);
-};
-
-typedef struct hw_interrupt_type  hw_irq_controller;
-
-/*
- * This is the "IRQ descriptor", which contains various information
- * about the irq, including what kind of hardware handling it has,
- * whether it is disabled etc etc.
- *
- * Pad this out to 32 bytes for cache and indexing reasons.
- */
-typedef struct {
-       unsigned int status;            /* IRQ status */
-       hw_irq_controller *handler;
-       struct irqaction *action;       /* IRQ action list */
-       unsigned int depth;             /* nested irq disables */
-       spinlock_t lock;
-} ____cacheline_aligned irq_desc_t;
-
-extern irq_desc_t irq_desc [NR_IRQS];
-
-#include <asm/hw_irq.h> /* the arch dependent stuff */
-
-extern int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
-extern int setup_irq(unsigned int , struct irqaction * );
-extern int teardown_irq(unsigned int , struct irqaction * );
-
-extern hw_irq_controller no_irq_type;  /* needed in every arch ? */
-extern void no_action(int cpl, void *dev_id, struct pt_regs *regs);
-
-#endif
-
-#endif /* __irq_h */
diff --git a/linux-2.4.28-xen-sparse/include/linux/irq.h b/linux-2.4.28-xen-sparse/include/linux/irq.h
new file mode 100644 (file)
index 0000000..7052672
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef __irq_h
+#define __irq_h
+
+/*
+ * Please do not include this file in generic code.  There is currently
+ * no requirement for any architecture to implement anything held
+ * within this file.
+ *
+ * Thanks. --rmk
+ */
+
+#include <linux/config.h>
+
+#if !defined(CONFIG_ARCH_S390)
+
+#include <linux/cache.h>
+#include <linux/spinlock.h>
+
+#include <asm/irq.h>
+#include <asm/ptrace.h>
+
+/*
+ * IRQ line status.
+ */
+#define IRQ_INPROGRESS 1       /* IRQ handler active - do not enter! */
+#define IRQ_DISABLED   2       /* IRQ disabled - do not enter! */
+#define IRQ_PENDING    4       /* IRQ pending - replay on enable */
+#define IRQ_REPLAY     8       /* IRQ has been replayed but not acked yet */
+#define IRQ_AUTODETECT 16      /* IRQ is being autodetected */
+#define IRQ_WAITING    32      /* IRQ not yet seen - for autodetection */
+#define IRQ_LEVEL      64      /* IRQ level triggered */
+#define IRQ_MASKED     128     /* IRQ masked - shouldn't be seen again */
+#define IRQ_PER_CPU    256     /* IRQ is per CPU */
+
+/*
+ * Interrupt controller descriptor. This is all we need
+ * to describe about the low-level hardware. 
+ */
+struct hw_interrupt_type {
+       const char * typename;
+       unsigned int (*startup)(unsigned int irq);
+       void (*shutdown)(unsigned int irq);
+       void (*enable)(unsigned int irq);
+       void (*disable)(unsigned int irq);
+       void (*ack)(unsigned int irq);
+       void (*end)(unsigned int irq);
+       void (*set_affinity)(unsigned int irq, unsigned long mask);
+};
+
+typedef struct hw_interrupt_type  hw_irq_controller;
+
+/*
+ * This is the "IRQ descriptor", which contains various information
+ * about the irq, including what kind of hardware handling it has,
+ * whether it is disabled etc etc.
+ *
+ * Pad this out to 32 bytes for cache and indexing reasons.
+ */
+typedef struct {
+       unsigned int status;            /* IRQ status */
+       hw_irq_controller *handler;
+       struct irqaction *action;       /* IRQ action list */
+       unsigned int depth;             /* nested irq disables */
+       spinlock_t lock;
+} ____cacheline_aligned irq_desc_t;
+
+extern irq_desc_t irq_desc [NR_IRQS];
+
+#include <asm/hw_irq.h> /* the arch dependent stuff */
+
+extern int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *);
+extern int setup_irq(unsigned int , struct irqaction * );
+extern int teardown_irq(unsigned int , struct irqaction * );
+
+extern hw_irq_controller no_irq_type;  /* needed in every arch ? */
+extern void no_action(int cpl, void *dev_id, struct pt_regs *regs);
+
+#endif
+
+#endif /* __irq_h */
diff --git a/linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile b/linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile
new file mode 100644 (file)
index 0000000..e25eb72
--- /dev/null
@@ -0,0 +1,16 @@
+obj-y  := main.o
+c-obj-y        := if.o
+
+c-link :=
+
+$(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-link)): $(obj)/mtrr.h
+       @ln -fsn $(srctree)/arch/i386/kernel/cpu/mtrr/$(notdir $@) $@
+
+$(patsubst %.o,$(obj)/%.c,$(obj-y)): $(obj)/mtrr.h
+
+$(obj)/mtrr.h:
+       @ln -fsn $(srctree)/arch/i386/kernel/cpu/mtrr/mtrr.h $@
+
+obj-y  += $(c-obj-y)
+
+clean-files += $(patsubst %.o,%.c,$(c-obj-y) $(c-obj-) $(c-link))
diff --git a/linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c b/linux-2.6.10-rc2-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c
new file mode 100644 (file)
index 0000000..c06cf93
--- /dev/null
@@ -0,0 +1,165 @@
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/ctype.h>
+#include <linux/module.h>
+#include <linux/seq_file.h>
+#include <asm/uaccess.h>
+
+#include <asm/mtrr.h>
+#include "mtrr.h"
+
+void generic_get_mtrr(unsigned int reg, unsigned long *base,
+                     unsigned int *size, mtrr_type * type)
+{
+       dom0_op_t op;
+
+       op.cmd = DOM0_READ_MEMTYPE;
+       op.u.read_memtype.reg = reg;
+       (void)HYPERVISOR_dom0_op(&op);
+
+       *size = op.u.read_memtype.nr_pfns;
+       *base = op.u.read_memtype.pfn;
+       *type = op.u.read_memtype.type;
+}
+
+struct mtrr_ops generic_mtrr_ops = {
+       .use_intel_if      = 1,
+       .get               = generic_get_mtrr,
+};
+
+struct mtrr_ops *mtrr_if = &generic_mtrr_ops;
+unsigned int num_var_ranges;
+unsigned int *usage_table;
+
+void __init set_num_var_ranges(void)
+{
+       dom0_op_t op;
+
+       for (num_var_ranges = 0; ; num_var_ranges++) {
+               op.cmd = DOM0_READ_MEMTYPE;
+               op.u.read_memtype.reg = num_var_ranges;
+               if (HYPERVISOR_dom0_op(&op) != 0)
+                       break;
+       }
+}
+
+static void __init init_table(void)
+{
+       int i, max;
+
+       max = num_var_ranges;
+       if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL))
+           == NULL) {
+               printk(KERN_ERR "mtrr: could not allocate\n");
+               return;
+       }
+       for (i = 0; i < max; i++)
+               usage_table[i] = 0;
+}
+
+int mtrr_add_page(unsigned long base, unsigned long size, 
+                 unsigned int type, char increment)
+{
+       int error;
+       dom0_op_t op;
+
+       op.cmd = DOM0_ADD_MEMTYPE;
+       op.u.add_memtype.pfn     = base;
+       op.u.add_memtype.nr_pfns = size;
+       op.u.add_memtype.type    = type;
+       if ((error = HYPERVISOR_dom0_op(&op)))
+               return error;
+
+       if (increment)
+               ++usage_table[op.u.add_memtype.reg];
+
+       return op.u.add_memtype.reg;
+}
+
+int
+mtrr_add(unsigned long base, unsigned long size, unsigned int type,
+        char increment)
+{
+       if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
+               printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
+               printk(KERN_DEBUG "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+               return -EINVAL;
+       }
+       return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
+                            increment);
+}
+
+int mtrr_del_page(int reg, unsigned long base, unsigned long size)
+{
+       int i, max;
+       mtrr_type ltype;
+       unsigned long lbase;
+       unsigned int lsize;
+       int error = -EINVAL;
+       dom0_op_t op;
+
+       max = num_var_ranges;
+       if (reg < 0) {
+               /*  Search for existing MTRR  */
+               for (i = 0; i < max; ++i) {
+                       mtrr_if->get(i, &lbase, &lsize, &ltype);
+                       if (lbase == base && lsize == size) {
+                               reg = i;
+                               break;
+                       }
+               }
+               if (reg < 0) {
+                       printk(KERN_DEBUG "mtrr: no MTRR for %lx000,%lx000 found\n", base,
+                              size);
+                       goto out;
+               }
+       }
+       if (usage_table[reg] < 1) {
+               printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
+               goto out;
+       }
+       if (--usage_table[reg] < 1) {
+               op.cmd = DOM0_DEL_MEMTYPE;
+               op.u.del_memtype.handle = 0;
+               op.u.add_memtype.reg    = reg;
+               (void)HYPERVISOR_dom0_op(&op);
+       }
+       error = reg;
+ out:
+       return error;
+}
+
+int
+mtrr_del(int reg, unsigned long base, unsigned long size)
+{
+       if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
+               printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
+               printk(KERN_DEBUG "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
+               return -EINVAL;
+       }
+       return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
+}
+
+EXPORT_SYMBOL(mtrr_add);
+EXPORT_SYMBOL(mtrr_del);
+
+static int __init mtrr_init(void)
+{
+       struct cpuinfo_x86 *c = &boot_cpu_data;
+
+       if (!(xen_start_info.flags & SIF_PRIVILEGED))
+               return -ENODEV;
+
+       if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
+           (!cpu_has(c, X86_FEATURE_K6_MTRR)) &&
+           (!cpu_has(c, X86_FEATURE_CYRIX_ARR)) &&
+           (!cpu_has(c, X86_FEATURE_CENTAUR_MCR)))
+               return -ENODEV;
+
+       set_num_var_ranges();
+       init_table();
+
+       return 0;
+}
+
+subsys_initcall(mtrr_init);
index 708de3a928d0625d0b4ff0d9a27ec7bd9387d632..a1463c9009b66af796d48c8513b366a9cece71ad 100644 (file)
@@ -93,7 +93,7 @@ VM_MASK               = 0x00020000
 #define preempt_stop           XEN_BLOCK_EVENTS(%esi)
 #else
 #define preempt_stop
-#define resume_kernel          restore_all_enable_events
+#define resume_kernel          restore_all
 #endif
 
 #define SAVE_ALL_NO_EVENTMASK \
@@ -109,7 +109,7 @@ VM_MASK             = 0x00020000
        pushl %ebx; \
        movl $(__USER_DS), %edx; \
        movl %edx, %ds; \
-       movl %edx, %es
+       movl %edx, %es;
 
 #define SAVE_ALL \
        SAVE_ALL_NO_EVENTMASK; \
@@ -397,6 +397,7 @@ vector=vector+1
        ALIGN
 common_interrupt:
        SAVE_ALL
+       movl %esp,%eax
        call do_IRQ
        jmp ret_from_intr
 
@@ -404,7 +405,8 @@ common_interrupt:
 ENTRY(name)                            \
        pushl $nr-256;                  \
        SAVE_ALL                        \
-       call smp_/**/name;      \
+       movl %esp,%eax;                 \
+       call smp_/**/name;              \
        jmp ret_from_intr;
 
 /* The include is where all of the SMP etc. interrupts come from */
@@ -437,7 +439,7 @@ error_code:
        movl %ecx, %es
        movl %esp,%eax                  # pt_regs pointer
        XEN_GET_VCPU_INFO(%esi)
-       XEN_SAVE_UPCALL_MASK(%esi,%dl,EVENT_MASK+8)
+       XEN_SAVE_UPCALL_MASK(%esi,%bl,EVENT_MASK)
        call *%edi
        jmp ret_from_exception
 
@@ -596,7 +598,7 @@ debug_stack_correct:
        movl %esp,%eax                  # pt_regs pointer
        call do_debug
        testl %eax,%eax
-       jnz restore
+       jnz restore_all
        jmp ret_from_exception
 
 #if 0 /* XEN */
@@ -721,7 +723,7 @@ ENTRY(page_fault)
        movl %eax, %es
        movl %esp,%eax                  /* pt_regs pointer */
        XEN_GET_VCPU_INFO(%esi)
-       XEN_SAVE_UPCALL_MASK(%esi,%bl,EVENT_MASK+12)
+       XEN_SAVE_UPCALL_MASK(%esi,%bl,EVENT_MASK)
        call do_page_fault
        jmp ret_from_exception
 
diff --git a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile
deleted file mode 100644 (file)
index e25eb72..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-obj-y  := main.o
-c-obj-y        := if.o
-
-c-link :=
-
-$(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-link)): $(obj)/mtrr.h
-       @ln -fsn $(srctree)/arch/i386/kernel/cpu/mtrr/$(notdir $@) $@
-
-$(patsubst %.o,$(obj)/%.c,$(obj-y)): $(obj)/mtrr.h
-
-$(obj)/mtrr.h:
-       @ln -fsn $(srctree)/arch/i386/kernel/cpu/mtrr/mtrr.h $@
-
-obj-y  += $(c-obj-y)
-
-clean-files += $(patsubst %.o,%.c,$(c-obj-y) $(c-obj-) $(c-link))
diff --git a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c
deleted file mode 100644 (file)
index c06cf93..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-#include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/seq_file.h>
-#include <asm/uaccess.h>
-
-#include <asm/mtrr.h>
-#include "mtrr.h"
-
-void generic_get_mtrr(unsigned int reg, unsigned long *base,
-                     unsigned int *size, mtrr_type * type)
-{
-       dom0_op_t op;
-
-       op.cmd = DOM0_READ_MEMTYPE;
-       op.u.read_memtype.reg = reg;
-       (void)HYPERVISOR_dom0_op(&op);
-
-       *size = op.u.read_memtype.nr_pfns;
-       *base = op.u.read_memtype.pfn;
-       *type = op.u.read_memtype.type;
-}
-
-struct mtrr_ops generic_mtrr_ops = {
-       .use_intel_if      = 1,
-       .get               = generic_get_mtrr,
-};
-
-struct mtrr_ops *mtrr_if = &generic_mtrr_ops;
-unsigned int num_var_ranges;
-unsigned int *usage_table;
-
-void __init set_num_var_ranges(void)
-{
-       dom0_op_t op;
-
-       for (num_var_ranges = 0; ; num_var_ranges++) {
-               op.cmd = DOM0_READ_MEMTYPE;
-               op.u.read_memtype.reg = num_var_ranges;
-               if (HYPERVISOR_dom0_op(&op) != 0)
-                       break;
-       }
-}
-
-static void __init init_table(void)
-{
-       int i, max;
-
-       max = num_var_ranges;
-       if ((usage_table = kmalloc(max * sizeof *usage_table, GFP_KERNEL))
-           == NULL) {
-               printk(KERN_ERR "mtrr: could not allocate\n");
-               return;
-       }
-       for (i = 0; i < max; i++)
-               usage_table[i] = 0;
-}
-
-int mtrr_add_page(unsigned long base, unsigned long size, 
-                 unsigned int type, char increment)
-{
-       int error;
-       dom0_op_t op;
-
-       op.cmd = DOM0_ADD_MEMTYPE;
-       op.u.add_memtype.pfn     = base;
-       op.u.add_memtype.nr_pfns = size;
-       op.u.add_memtype.type    = type;
-       if ((error = HYPERVISOR_dom0_op(&op)))
-               return error;
-
-       if (increment)
-               ++usage_table[op.u.add_memtype.reg];
-
-       return op.u.add_memtype.reg;
-}
-
-int
-mtrr_add(unsigned long base, unsigned long size, unsigned int type,
-        char increment)
-{
-       if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
-               printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
-               printk(KERN_DEBUG "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
-               return -EINVAL;
-       }
-       return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
-                            increment);
-}
-
-int mtrr_del_page(int reg, unsigned long base, unsigned long size)
-{
-       int i, max;
-       mtrr_type ltype;
-       unsigned long lbase;
-       unsigned int lsize;
-       int error = -EINVAL;
-       dom0_op_t op;
-
-       max = num_var_ranges;
-       if (reg < 0) {
-               /*  Search for existing MTRR  */
-               for (i = 0; i < max; ++i) {
-                       mtrr_if->get(i, &lbase, &lsize, &ltype);
-                       if (lbase == base && lsize == size) {
-                               reg = i;
-                               break;
-                       }
-               }
-               if (reg < 0) {
-                       printk(KERN_DEBUG "mtrr: no MTRR for %lx000,%lx000 found\n", base,
-                              size);
-                       goto out;
-               }
-       }
-       if (usage_table[reg] < 1) {
-               printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
-               goto out;
-       }
-       if (--usage_table[reg] < 1) {
-               op.cmd = DOM0_DEL_MEMTYPE;
-               op.u.del_memtype.handle = 0;
-               op.u.add_memtype.reg    = reg;
-               (void)HYPERVISOR_dom0_op(&op);
-       }
-       error = reg;
- out:
-       return error;
-}
-
-int
-mtrr_del(int reg, unsigned long base, unsigned long size)
-{
-       if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
-               printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
-               printk(KERN_DEBUG "mtrr: size: 0x%lx  base: 0x%lx\n", size, base);
-               return -EINVAL;
-       }
-       return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
-}
-
-EXPORT_SYMBOL(mtrr_add);
-EXPORT_SYMBOL(mtrr_del);
-
-static int __init mtrr_init(void)
-{
-       struct cpuinfo_x86 *c = &boot_cpu_data;
-
-       if (!(xen_start_info.flags & SIF_PRIVILEGED))
-               return -ENODEV;
-
-       if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
-           (!cpu_has(c, X86_FEATURE_K6_MTRR)) &&
-           (!cpu_has(c, X86_FEATURE_CYRIX_ARR)) &&
-           (!cpu_has(c, X86_FEATURE_CENTAUR_MCR)))
-               return -ENODEV;
-
-       set_num_var_ranges();
-       init_table();
-
-       return 0;
-}
-
-subsys_initcall(mtrr_init);